package com.bw.zhuangao5___day002.Fragment.Home.Fragment1;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * create by ertu
 * create on 2021/9/24
 * description
 */
public class HomeOkhttps {
    public static HomeOkhttps homeOkhttps;
    public Retrofit retrofit;
    public static HomeOkhttps getHomeOkhttps()
    {
        if (homeOkhttps==null)
        {
            synchronized (HomeOkhttps.class)
            {
                if (homeOkhttps==null){
                    homeOkhttps = new HomeOkhttps();
                }
            }
        }
        return homeOkhttps;
    }


    public Retrofit retrofits()
    {
         if (retrofit==null)
         {
             synchronized (Retrofit.class){
                 if (retrofit==null)
                 {
                     retrofit = new Retrofit.Builder().baseUrl("http://service.picasso.adesk.com/")
                             .client(new OkHttpClient.Builder()
                                     .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                                     .build())
                             .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                             .addConverterFactory(GsonConverterFactory.create())
                             .build();
                 }
             }
         }
             return retrofit;
    }
}
